package implementor;

import daoInterface.TransactionDao;
import dbhandeling.Crude;
import dto.Transactions;

public class TransactionDaoImplementor extends Crude implements TransactionDao
{
String className=new Transactions().getClass().getName();
@Override
public void add(Transactions transactions) throws Exception
{
insert(transactions);
}
/***********************************************************/
@Override
public void update(Transactions transactions) throws Exception
{
super.update(className,"transCatId",transactions.gettransCatId()+"","autoTransactionId",transactions.getautoTransactionId()+"");
super.update(className,"amt",transactions.getamt()+"","autoTransactionId",transactions.getautoTransactionId()+"");
super.update(className,"date",transactions.getdate()+"","autoTransactionId",transactions.getautoTransactionId()+"");
super.update(className,"status",transactions.getstatus()+"","autoTransactionId",transactions.getautoTransactionId()+"");
super.update(className,"comments",transactions.getcomments()+"","autoTransactionId",transactions.getautoTransactionId()+"");
super.update(className,"balancePaymentId",transactions.getbalancePaymentId()+"","autoTransactionId",transactions.getautoTransactionId()+"");
}
/***********************************************************/
@Override
public void delete(Transactions transactions) throws Exception
{
super.delete(className,"autoTransactionId",transactions.getautoTransactionId()+"");
}
/***********************************************************/
@Override
public Transactions retrieve(String conditionField,String conditionValue) throws Exception
{
Transactions transactions=(Transactions) super.retreive(className,conditionField,conditionValue);
return transactions;
}
/***********************************************************/
@Override
public Transactions[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Transactions[] transaction;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
transaction=new Transactions[obj.length];
for(int i=0;i<transaction.length;i++)
{
transaction[i]=(Transactions) obj[i];
}
return transaction;
}
/***********************************************************/
@Override
public Transactions[] retrieveAll() throws Exception
{
Transactions[] transaction;
Object[] obj=super.retreiveAll(className);
transaction=new Transactions[obj.length];
for(int i=0;i<transaction.length;i++)
{
transaction[i]=(Transactions) obj[i];
}
return transaction;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoTransactionId") ;
	 return key;
}
}
